package com.hy.dao.impl;
/*
 * @ Date: 2024/5/14 22:34
 * @ Description: InstorePartstableDaoImpl
 **/

import com.hy.bean.InstorePartstable;
import com.hy.dao.InstorePartstableDao;
import com.hy.exception.BizException;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.math.BigInteger;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class InstorePartstableDaoImpl implements InstorePartstableDao {
    private final QueryRunner queryRunner = new QueryRunner();
    @Override
    public InstorePartstable queryById(Integer id) {
        return null;
    }

    @Override
    public List<InstorePartstable> queryAllByLimit() {
        return null;
    }

    @Override
    public long count(InstorePartstable instorePartstable) {
        return 0;
    }

    @Override
    public int insert(Connection connection, InstorePartstable instorePartstable) {
        String sql = "INSERT INTO instore_partstable (inStoreTable_id, partTable_id, inStoreCount) VALUES (?, ?, ?)";
        try {
            BigInteger insert = queryRunner.insert(connection, sql, new ScalarHandler<>(), instorePartstable.getInstoretableId(), instorePartstable.getParttableId(), instorePartstable.getInstorecount());
            return insert.intValue();
        } catch (SQLException e) {
            throw new BizException("插入入库明细失败");
        }
    }

    @Override
    public int update(InstorePartstable instorePartstable) {
        return 0;
    }

    @Override
    public int deleteById(Integer id) {
        return 0;
    }
}
